<template>
  <div id="app">
    <router-view v-if="isRouterAlive" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      isRouterAlive: true,
    }
  },
  // 父组件中返回要传给下级的数据
  provide() {
    return {
      reload: this.reload, // 把reload方法传递给子组件、子路由
    }
  },
  methods: {
    reload() {
      console.log('正在刷新组件...')
      this.isRouterAlive = false
      this.$nextTick(() => {
        console.log('正在渲染dom...')
        this.isRouterAlive = true
        this.$nextTick(() => {
          console.log('dom渲染完成')
        })
      })
    },
  },
}
</script>

<style lang="scss">
@import './assets/css/main.css';
</style>
